package server;

import java.io.DataInputStream;
import java.io.IOException;
import java.net.Socket;
import java.util.Map;
import java.util.TreeMap;

import util.Command;
import util.Statistically;

public class TaskServer implements Runnable {
	private Socket socket;	
	private Command serverCommands[];
	
	public TaskServer(Socket sck) throws IOException{
		socket = sck;		
		serverCommands = new Command[2];
		serverCommands[0] = new server.command.Get();
		serverCommands[1] = new server.command.Put();
	}
	@Override
	public void run() {
		String id = socket.getInetAddress().toString() + socket.getPort();
		try {					
			DataInputStream data_in = new DataInputStream(socket.getInputStream());
			int op = data_in.readInt();
			serverCommands[op].setSocket(socket);
			serverCommands[op].execute();			
		} catch (IOException e) {
			e.printStackTrace();
		}
	}	
}
